﻿using System;
using System.Collections.Generic;
using System.Linq;
using ZY.EntityFrameWork.Caller.Facade;
using ZY.EntityFrameWork.Core.DBHelper;
using ZY.EntityFrameWork.Core.Model.Dto;
using ZY.EntityFrameWork.Core.Model.Dto.Authority;
using ZY.EntityFrameWork.Core.Model.Entity;
using ZY.EntityFrameWork.Core.Model.Entity.Authority;
using ZY.EntityFrameWork.Core.Services;

namespace ZY.EntityFrameWork.Caller.WinformCaller
{
    public partial class WinAuthorityService:BaseAuthorityService,IAuthorityService
    {
        public int AddNewUser(UserDto userDto)
        {
            User user = userDto.MapTo<User>();
            Role role = base.GetUserRole(userDto.RoleName);
            if (role == null)
                throw new Exception("角色不存在！");
            user.RoleId = role.Id;
            return base.AddNewUser(user.MapTo<User>());
        }

        //public bool CheckUser(string userCode, string passWord)
        //{
        //    return base.CheckUser(userCode, passWord);
        //}

        new public List<UserDto> GetAllUsers()
        {
            return base.GetAllUsers().MapTo<List<UserDto>>();
        }
    }
}
